package com.buddies.lottery.ui.withdraw.record;

import com.buddies.lottery.base.list.BaseListPresenter;
import com.buddies.lottery.data.BaseObserver;
import com.buddies.lottery.data.DataManager;
import com.buddies.lottery.data.bean.WithdrawRecord;
import com.buddies.lottery.data.result.PageResult;

import java.util.Map;

public class WithdrawRecordPresenter extends BaseListPresenter<WithdrawRecordContract.View> implements WithdrawRecordContract.Presenter {

    public WithdrawRecordPresenter(WithdrawRecordContract.View view) {
        super(view);
    }

    @Override
    public WithdrawRecordContract.View getView() {
        return ((WithdrawRecordContract.View) mView);
    }

    @Override
    public void onLoadData(Map<String, Object> params, int page) {
        addSubscription(DataManager.getInstance().getUserRepo().getWithdrawRecord(page), new BaseObserver<PageResult<WithdrawRecord>>() {
            @Override
            public void onNext(PageResult<WithdrawRecord> response) {
                getView().onDataLoaded(response);
            }

            @Override
            public void onError(Throwable e) {
                getView().onError(e);
            }
        });
    }

}
